﻿<%@ Page Title="Kunder" Language="C#" MasterPageFile="~/TsSite.Master" AutoEventWireup="true" CodeBehind="CustomerList.aspx.cs" Inherits="TireService.Web.View.CustomerView.CustomerList" %>

<%@ Register assembly="DevExpress.Web.v11.1, Version=11.1.12.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a" namespace="DevExpress.Web.ASPxPanel" tagprefix="dx" %>
<%@ Register Assembly="DevExpress.Web.v11.1, Version=11.1.12.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a" Namespace="DevExpress.Web.ASPxRoundPanel" TagPrefix="dx" %>
<%@ Register Assembly="DevExpress.Web.ASPxGridView.v11.1.Export, Version=11.1.12.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a" Namespace="DevExpress.Web.ASPxGridView.Export" TagPrefix="dxwgv" %>
<%@ Register assembly="DevExpress.Web.ASPxGridView.v11.1, Version=11.1.12.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a" namespace="DevExpress.Web.ASPxGridView" tagprefix="dxwgv" %>
<%@ Register assembly="DevExpress.Web.ASPxEditors.v11.1, Version=11.1.12.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a" namespace="DevExpress.Web.ASPxEditors" tagprefix="dxe" %>

<%@ Register src="../../UserControls/ucCreateTask.ascx" tagname="ucCreateTask" tagprefix="uc1" %>

<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
</asp:Content>

<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
                
    <table cellpadding="0" cellspacing="2" border="0">
        <tr>
            <td>
                <img id="imgCustomer" alt="" src="~/Images/Medium/businessmen.png" runat="server" style="width: 32px; height: 32px" />
            </td>
            <td valign="middle">
                <h3><asp:Label ID="lblCustomerHeader" runat="server" Text="Kunder"></asp:Label></h3>
            </td>
        </tr>
    </table>
    <hr />

    <!-- Javascript -->
    <script language="javascript" type="text/javascript">

        // Function that handles actions selected in dropdown list
        function ActionClicked() {

            // Get selected action from dropdownlist
            var id = ddlAction.GetValue();

            if (id != null && id != 0) {

                
            }
            else {
                alert('Ingen handling valgt');
            }
        }

        // -- Implementation script for Create Task UserControl --
        // Functions for create task modalpopup
        function ShowCreateTaskModalPopup(element, key) {
            callbackCreateTaskPanel.SetContentHtml("");
            pcCreateTask.ShowAtElement(element);
            callbackCreateTaskPanel.PerformCallback('NoAction' + '|' + key);
            //ddlCar.PerformCallback(key.toString());
            CreateTaskCustomerIdKeyValue = key;
        }

    </script>
                
    <table border="0" cellspacing="0" cellpadding="5" width="100%">
        <tr>
            <td style="width:150px">
                <dxe:ASPxComboBox ID="ddlAction" ClientInstanceName="ddlAction" runat="server" Width="150px">
                    <Items>
                        <dxe:ListEditItem Selected="true" Value="0" Text="-- Handling --" />
                        <dxe:ListEditItem Value="1" Text="Vis booking link" />
                    </Items>
                </dxe:ASPxComboBox>
            </td>
            <td style="width:75px">
                <dxe:ASPxButton ID="btnSubmitAction" runat="server" Text="Udfør" AutoPostBack="False" UseSubmitBehavior="False" Width="75px">
                    <ClientSideEvents Click="function(s, e) { ActionClicked(); }" />
                </dxe:ASPxButton>
            </td>
            <td style="width:150px">
                <dxe:ASPxComboBox ID="ddlExport" ClientInstanceName="ddlExport" runat="server" Width="150px">
                    <Items>
                        <dxe:ListEditItem Selected="True" Value="0" Text="Export pdf" />
                        <dxe:ListEditItem Value="1" Text="Export xls" />
                        <dxe:ListEditItem Value="2" Text="Export csv" />
                        <dxe:ListEditItem Value="3" Text="Export rtf" />
                    </Items>
                </dxe:ASPxComboBox>
            </td>
            <td style="width:75px">
                <dxe:ASPxButton ID="btnExport" runat="server" Text="Exporter" OnClick="btnExport_Click" Width="75px" >
                </dxe:ASPxButton>
            </td>
            <td style="width:125px">
                <dxe:ASPxButton ID="btnCreateCustomer" runat="server" Text="Opret kunde" Width="125px" PostBackUrl="~/View/CustomerView/EditCustomerData.aspx" >
                </dxe:ASPxButton>
            </td>
            <td align="right">
                <asp:Label ID="lblView" runat="server" Text="Visning"></asp:Label>
                <asp:DropDownList ID="ddlView" runat="server" AutoPostBack="True" 
                    onselectedindexchanged="ddlView_SelectedIndexChanged">
                    <asp:ListItem Value="0">Ingen gruppering</asp:ListItem>
                    <asp:ListItem Value="1">Grupper efter Postnr</asp:ListItem>
                </asp:DropDownList>
                &nbsp;
                <asp:Label ID="lblPageSize" runat="server" Text="Antal linjer pr side"></asp:Label>
                <asp:DropDownList ID="ddlPageSize" runat="server" AutoPostBack="true">
                    <asp:ListItem Value="10">10</asp:ListItem>
                    <asp:ListItem Value="25">25</asp:ListItem>
                    <asp:ListItem Value="50">50</asp:ListItem>
                    <asp:ListItem Value="100">100</asp:ListItem>
                </asp:DropDownList>
            </td>
        </tr>
    </table>          
    <hr />
    
    <dxwgv:ASPxGridView ID="gvCustomer" runat="server" ClientInstanceName="gvCustomer" 
        KeyFieldName="CustomerId" Width="100%" AutoGenerateColumns="False" EnableCallBacks="True" 
        oncustomunboundcolumndata="gvCustomer_CustomUnboundColumnData" >
        <SettingsLoadingPanel Text="Henter&amp;hellip;" />
        <Settings ShowHeaderFilterButton="true" ShowGroupPanel="true" ShowFilterRow="True" />
        <SettingsPager AlwaysShowPager="True" PageSize="25" Position="TopAndBottom">
            <Summary 
                AllPagesText="Sider: {0} - {1} ({2} kunder)" 
                Text="Side {0} af {1} ({2} kunder)" />
        </SettingsPager>
        <SettingsText ConfirmDelete="Vil du slette denne kunde?" GroupPanel="Træk kolonne hertil for at gruppere efter den" HeaderFilterShowAll="Vis alle" />
        <SettingsBehavior ConfirmDelete="True" AllowGroup="true" AllowDragDrop="true" />
                            
        <Columns>
            <dxwgv:GridViewCommandColumn ShowSelectCheckbox="True" VisibleIndex="0">
                    <HeaderTemplate>
                        <input type="checkbox" onclick="gvCustomer.SelectAllRowsOnPage(this.checked);" style="vertical-align:middle;" title="Vælg/Fravælg alle linjer på siden"></input>
                    </HeaderTemplate>
                    <HeaderStyle Paddings-PaddingTop="1" Paddings-PaddingBottom="1" 
                        HorizontalAlign="Center">
                    <Paddings PaddingTop="1px" PaddingBottom="1px"></Paddings>
                    </HeaderStyle>
            </dxwgv:GridViewCommandColumn>
            <dxwgv:GridViewDataColumn Caption="Rediger" Width="92px" VisibleIndex="1">
                <DataItemTemplate>                    
                    <a href="javascript:void(0);" onclick="ShowCreateTaskModalPopup(this, '<%# Container.KeyValue %>')"><img src="~/Images/Tiny/contract.png" id="imgWheel" runat="server" alt="Opret opgave" /></a>
                </DataItemTemplate>
            </dxwgv:GridViewDataColumn>
            <dxwgv:GridViewDataHyperLinkColumn FieldName="CustomerId" VisibleIndex="0" Caption="Kundenr">
                <PropertiesHyperLinkEdit NavigateUrlFormatString="~/View/CustomerView/EditCustomerData.aspx?CustomerId={0}" TextField="CustomerId">
                </PropertiesHyperLinkEdit>
            </dxwgv:GridViewDataHyperLinkColumn>
            <dxwgv:GridViewDataHyperLinkColumn FieldName="ParentCustomerId" VisibleIndex="2" Caption="Afdeling">
                <PropertiesHyperLinkEdit NavigateUrlFormatString="~/View/CustomerView/EditCustomerData.aspx?CustomerId={0}" TextField="ParentCompanyName">
                </PropertiesHyperLinkEdit>
            </dxwgv:GridViewDataHyperLinkColumn>
            <dxwgv:GridViewDataColumn FieldName="CompanyName" VisibleIndex="3" Caption="Firma">
            </dxwgv:GridViewDataColumn>
            <dxwgv:GridViewDataColumn FieldName="Name" VisibleIndex="3" Caption="Navn">
            </dxwgv:GridViewDataColumn>
            <dxwgv:GridViewDataColumn FieldName="Address" VisibleIndex="4" Caption="Adresse">
            </dxwgv:GridViewDataColumn>
            <dxwgv:GridViewDataColumn FieldName="ZipCode" VisibleIndex="5" Caption="Postnr">
            </dxwgv:GridViewDataColumn>
            <dxwgv:GridViewDataColumn FieldName="City" VisibleIndex="6" Caption="By">
            </dxwgv:GridViewDataColumn>
            <dxwgv:GridViewDataColumn FieldName="CountryId" VisibleIndex="7" Caption="CountryId" Visible="false">
            </dxwgv:GridViewDataColumn>
            <dxwgv:GridViewDataTextColumn FieldName="CountryName" VisibleIndex="8" UnboundType="String" Caption="Land">
            </dxwgv:GridViewDataTextColumn>
            <%--<dxwgv:GridViewDataColumn FieldName="SecondaryAddress" VisibleIndex="9" Caption="Sekundær Adresse">
            </dxwgv:GridViewDataColumn>
            <dxwgv:GridViewDataColumn FieldName="SecondaryZipCode" VisibleIndex="10" Caption="Sekundær Postnr">
            </dxwgv:GridViewDataColumn>
            <dxwgv:GridViewDataColumn FieldName="SecondaryCity" VisibleIndex="11" Caption="Sekundær By">
            </dxwgv:GridViewDataColumn>--%>
            <dxwgv:GridViewDataColumn FieldName="Phone1" VisibleIndex="12" Caption="Telefon">
            </dxwgv:GridViewDataColumn>
            <dxwgv:GridViewDataColumn FieldName="Phone2" VisibleIndex="13" Caption="Telefon2">
            </dxwgv:GridViewDataColumn>
            <dxwgv:GridViewDataColumn FieldName="Email" VisibleIndex="14" Caption="Email">
            </dxwgv:GridViewDataColumn>
        </Columns>
                            
    </dxwgv:ASPxGridView>
                
    <dxwgv:ASPxGridViewExporter ID="gvExport" runat="server" GridViewID="gvCustomer">
    </dxwgv:ASPxGridViewExporter>

    <uc1:ucCreateTask ID="ucCreateTask" runat="server" />

</asp:Content>
